package listfactory;

import factory.Item;
import factory.Tray;

import java.util.Iterator;

public class ListTray extends Tray {

    public ListTray(String caption){
        super(caption);
    }

    @Override
    public String makeHTML() {
        StringBuilder stringBuilder = new StringBuilder();
        stringBuilder.append("<li>");
        stringBuilder.append(caption);
        stringBuilder.append("<ul>");
        Iterator<Item> iterator = itemList.iterator();
        while (iterator.hasNext()){
            Item item = iterator.next();
            stringBuilder.append(item.makeHTML());
        }
        stringBuilder.append("</ul>");
        stringBuilder.append("</li>");
        return stringBuilder.toString();
    }
}
